/*
 * CommandeAvancer.cpp
 *
 *  Created on: 21 dec. 2012
 *      Author: guegan
 */

#include <cstdlib>
#include "CommandeAvancer.h"
#include "Invocateur.h"


CommandeAvancer* CommandeAvancer::instance = NULL;

CommandeAvancer* CommandeAvancer::getInstance() {
	if (instance == NULL)
		instance = new CommandeAvancer();
	
	return instance;
}

Commande* CommandeAvancer::constructeurVirtuel() {
	Commande* com = new CommandeAvancer();
	
	dynamic_cast<CommandeAvancer*>(com)->x = atoi(commandeur->getArg(1).c_str());
	dynamic_cast<CommandeAvancer*>(com)->y = atoi(commandeur->getArg(2).c_str());
	
	return com;
}

void CommandeAvancer::execute() {
	old_x = bot->getPosition()->getX();
	old_y = bot->getPosition()->getY();
	
	bot->avancer(x, y);
}

void CommandeAvancer::desexecute() {
	bot->avancer(old_x, old_y);
}

bool CommandeAvancer::reversible() {
	return true;
}

